package org.refresh.emf;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.refresh.core.intelligence.ObjectView;

/******************************************************************************
 * Copyright (c) 2005, 2006 Jules White.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Jules White - initial API and implementation 
 ****************************************************************************/
public class EMFView implements ObjectView{

	/* (non-Javadoc)
	 * @see org.refresh.core.intelligence.ObjectView#getView(java.lang.Object)
	 */
	public Map getView(Object obj) {
		EObject eobj = (EObject)obj;
		HashMap view = new HashMap();
		for(EStructuralFeature f : eobj.eClass().getEAllStructuralFeatures()){
			view.put(f.getName(), eobj.eGet(f));
		}
		return view;
	}

	/* (non-Javadoc)
	 * @see org.refresh.core.intelligence.ObjectView#supports(java.lang.Object)
	 */
	public boolean supports(Object obj) {
		return obj instanceof EObject;
	}

	
}
